package com.wcx.behavior.strategy.demo1;

/**
 * 项目: design-pattern-githupdemo
 * <p>
 * 功能描述:
 *
 * @author: WuChengXing
 * @create: 2021-01-09 10:41
 **/
public class CashContext {

    private CashSuper cashSuper;

    public CashContext(String type) {
        switch (type) {
            case "1":
                cashSuper = new CashSuperNormal();
                break;
            case "2":
                cashSuper = new CashSuperRebate(0.8d);
                break;
            default:
                cashSuper = null;
                break;
        }
    }

    /**
     * 求出最后的结果
     *
     * @return
     */
    public double getResult(double money) {
        return cashSuper.acceptCash(money);
    }
}
